package UIFree.slideshow
{
	import Classes.CLoader;
	
	import UIFree.ObjectEvent;
	import UIFree.effects.ef_flames;
	import UIFree.effects.flames.ef_duoFlame;
	import UIFree.effects.flames.ef_flame;
	import UIFree.effects.uif_effect;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	public class fadeExample extends uif_ecomponent {
		public function fadeExample(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, styleClass:String='') {
			super(parent, ax, ay, awidth, aheight, styleClass);
			
			var rect: Rectangle = getInner();
			var ssf: ss_slideFade = new ss_slideFade(This, rect.x, rect.y, rect.width, rect.height, 'blue');
			
			function assignSource(e: Event): void {
				ssf.assignSource(e.target.loader);
				if (ssf.isInAndOut) {
					ssf.start(ef_flames, {
						live				: 0,
						density				: 0.8,
						flameStyle			: 'flame',
						flameSpeed			: [0, 0],
						flameLive			: 20,
						flameAtack			: 0.2,
						flameFade			: 0.2,
						flameClass			: ef_duoFlame,
						flameType			: ef_flame.RECTFLAME,
						flameVolumeChange 	: [1.05, 1.05],
						flameSize			: _source.width / 5
					}, 1000).addEvent(uif_effect.UPDATE, function(e: ObjectEvent): void {
						var mat: Matrix = new Matrix();
						mat.translate(e.object.options.flameSpeed[0], e.object.options.flameSpeed[1]);
						mat.concat(e.object.flame.transform.matrix);
						e.object.flame.transform.matrix = mat;
						e.object.flame.resize(e.object.flame.width * e.object.options.flameVolumeChange[0], e.object.flame.height * e.object.options.flameVolumeChange[1]);
					});
				}
			}

			var _source: CLoader = new CLoader(this, 'http://content.foto.mail.ru/mail/fwadim/106/i-2010.jpg', assignSource);
			_source.visible = false;
			
			_source = new CLoader(this, 'http://content.foto.mail.ru/mail/fwadim/29/i-2014.jpg', assignSource);
			_source.visible = false;
/*			_source = new pi_source(this, 0, 0, 400, 400);
			_source.loadSource('http://content.foto.mail.ru/mail/fwadim/29/i-2014.jpg', assignSource);
			_source.visible = false;*/
		}
		
	}
}